﻿(function (para) {
    var p = para.sdk_url, n = para.name, w = window, d = document, s = 'script', x = null, y = null;
    w['sensorsDataAnalytic201505'] = n;
    w[n] = w[n] || function (a) { return function () { (w[n]._q = w[n]._q || []).push([a, arguments]); } };
    var ifs = ['track', 'quick', 'register', 'registerPage', 'registerOnce', 'trackSignup', 'trackAbtest', 'setProfile', 'setOnceProfile', 'appendProfile', 'incrementProfile', 'deleteProfile', 'unsetProfile', 'identify', 'login', 'logout', 'trackLink', 'clearAllRegister', 'getAppStatus'];
    for (var i = 0; i < ifs.length; i++) {
        w[n][ifs[i]] = w[n].call(null, ifs[i]);
    }
    if (!w[n]._t) {
        x = d.createElement(s), y = d.getElementsByTagName(s)[0];
        x.async = 1;
        x.src = p;
        x.setAttribute('charset', 'UTF-8');
        y.parentNode.insertBefore(x, y);
        w[n].para = para;
    }
})({
    sdk_url: 'js/sensorsdata.min.js',
    heatmap_url: 'js/heatmap.min.js',
    name: 'sensors',
    //web_url: Ares.SensorsConfig.WebUrl,
    server_url: Ares.SensorsConfig.ServerUrl,
    heatmap: {
        clickmap: 'default',
        scroll_notice_map: 'not_collect',
        loadTimeout: 3000,
        collect_element: function (element_target) {
            if (element_target.getAttribute('sensors-enabled') === 'true') {
                return true;
            } else {
                return false;
            }
        },
        custom_property: function (element_target) {
            var eventName = element_target.getAttribute('sensors-event-name');
            var eventType = element_target.getAttribute('sensors-event-type');

            var customproperty = {
                EventName: eventName,
                EventType: eventType
            };

            if (location.href.indexOf('/#/') > 0) {
                var str = location.href.substring(location.href.indexOf('/#/') + 2);
                var pattern = /^\/patient\/.+(\/[\d]+)\//i;
                if (pattern.test(str)) {
                    var id = str.match(pattern)[1];
                    str = str.replace(id, "");
                }

                customproperty['$url_path'] = str;
            }

            return customproperty;
        }
    },
    debug_mode: false,
    show_log: false
});
Ares.sensors.login();
